﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace weba
{
    public partial class bianjidt : System.Web.UI.Page
    {
        public string tid;
        sjklqDataContext sj = new sjklqDataContext();
        protected void Page_Load(object sender, EventArgs e)
        {
            tid = Request.QueryString["id"];
            if (!IsPostBack)
            {
               dongtai xw = sj.dongtai.Where(h => h.Id.ToString() == tid).FirstOrDefault();
                Label1.Text = tid;
                C1InputText1.Text = xw.tit;
                C1Editor1.Text = xw.discp;
            }
        }

        protected void C1Editor1_TextSaved(object sender, EventArgs e)
        {
            dongtai sx = sj.dongtai.Single(h => h.Id.ToString() == tid);
            sx.tit = C1InputText1.Text;
            sx.discp = C1Editor1.Text;
            sx.shijian = DateTime.Now;
            sj.dongtai.InsertOnSubmit(sx);
            sj.SubmitChanges();
            Label2.Text = "更新成功";
           // HttpContext.Current.Response.Redirect(HttpContext.Current.Request.RawUrl);
            //Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "", "alert('添加成功')", true);
           
            //Response.Redirect(Request.RawUrl);
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            dongtai sx = sj.dongtai.Single(h => h.Id.ToString() == tid);
            sx.tit = C1InputText1.Text;
            sx.discp = C1Editor1.Text;
            sx.shijian = DateTime.Now;
            sj.SubmitChanges();
            Label2.Text = "更新成功";
        }
    }
}